<template>
    <div class="header-container">
        <div class="l-content">
            <el-button @click="handleMenu" icon="el-icon-menu" size="mini"></el-button>
            <!-- <span class="text">首页</span> -->
            <el-breadcrumb separator="/">
                <el-breadcrumb-item v-for="(item) in tagsLists" :key="item.name" :to="{ path: item.path }">{{ item.label
                }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="r-content">
            <el-dropdown @command="handleClick">
                <span class="el-dropdown-link">
                    <img class="user" src="@/assets/img/pic.png" alt="">
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item command="logout">退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>

        </div>
    </div>
</template>

<script>
import { mapState } from 'vuex';
import Cookies from 'js-cookie'
export default {
    data() {
        return {

        }
    },
    methods: {
        handleMenu() {
            this.$store.commit('collapseMenu');
        },
        handleClick(command) {
            if (command === 'logout') {
                Cookies.remove('token');
                Cookies.remove('menu');
                //跳转
                this.$router.push('/login')
            }
        }
    },
    computed: {
        ...mapState({
            tagsLists: state => state.tag.tagsLists
        })
    }
}
</script>

<style lang="scss" scoped>
.header-container {
    padding: 0 20px;
    background-color: #333;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .text {
        color: #fff;
        font-size: 14px;
        margin-left: 10px;
    }

    .l-content {
        display: flex;
        align-items: center;

        & ::v-deep .el-breadcrumb {
            padding: 10px;

            .el-breadcrumb__item {
                .el-breadcrumb__inner {
                    font-weight: normal;
                    color: #969696;

                }

                &:last-child {
                    .el-breadcrumb__inner {
                        font-weight: normal;
                        color: #fff;
                    }
                }
            }
        }
    }

    .r-content {
        .user {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            position: absolute;
            top: -26px;
            left: -32px;
        }
    }
}
</style>